Repository navigation
Conversation
Where a field read sits relative to a call or a test decides more of the match
than any other source choice measured over Map::Units::TroopValueState, and
quick_styles.py makes it cheap to settle:
recountTotalTroopValue 27.7% -> 49.5% (owner read after the call)
queueOilThrowForIdleArchers 70.7% -> 100% (field read after the tests)
collectArcherUnitsByLocation 49.4% -> 61.5% (index read inside the branch)
assignBehaviorTypeToNearbyTribes 46.6% -> 68.0% (argument hoisted out of the &&)
Also records that `if (x < N) { if (x == N) {...} }` is a flattened three-way
test whose inner arm is unreachable, and that the fall-through arm has to stay
first when rebuilding it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The decompiler lifts a field read to the top of its block; the original reads it where it is used, and which side of an intervening call or test the read falls on changes the allocation of everything around it. This writes one variant per candidate for quick_styles.py to score. It refuses to move a statement across a loop head or next to a use that reads the variable back, because either changes behaviour rather than allocation - the first version did both and produced a counter reset inside its own loop. Moving a read later still crosses whatever sits between, so the winner has to be read before it is kept. placeTunnelForEveryTunneler 52.1% -> 68.3%. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The first version only guarded against moving a statement *into* a loop. It also has to refuse moving one *out*: it lifted a pointer increment out of its own walk loop in computeSiegeSpotScores, which stops the walk advancing, and the broken variant won by 0.09 points. Now it tracks brace depth and rejects a target shallower than the source, plus any target that assigns the variable (which would make the moved statement dead). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Each of these produced a *winning* variant that was wrong: - moving a statement out of its enclosing block (pointer increment lifted out of its walk loop, computeSiegeSpotScores) - moving one across a goto-based loop (unit scan restarted per queue entry, placeSiegeTentsAndAssignEngineers) - moving one into a block that only some of its uses sit in (a switch arm left the other arms reading an uninitialised local, updateTribeBehavior) One won by 0.09 points, so the score is no protection; the docstring now says so and names aliasing as the part no guard covers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
playAttackAlarmSound: lay the switch arms out in the order the original's jump table implies - case 5 (drumhorn) ahead of cases 2/3/4 (battlehorn) - which takes it from 75% to an exact match. Also record in AGENTS.md that reccmp_report.py --run does not build, and that switch-arm source order decides the arm layout even for a jump-table switch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012MZnQwhZ2cjYqJdMdEo18X
…ayout order Both switches now lay their arms out in the order the original's jump tables imply, derived by sorting the distinct 'start + N' offsets and mapping each one back to its case value: behaviour switch (0x3f3..0x41e): 0x3ff, 0x3f6, 0x412, 0x413, 0x3f5, 0x3fb, 0x400, 0x3fe, 0x3fd, 0x414, 0x3f8, 0x3f9, 0x3f7, 0x416, 0x41b, 0x418, 0x419, 0x41a, 0x3fc, 0x411, 0x401, 0x3f3, 0x3f4, 0x406, 0x41e, default stance switch (1..8): 3, 4/6, 5, 7, 8, 1, default 'case 8' was the last arm and relied on falling out of the switch, so it gets an explicit break now that 'case 1' follows it. 37.80% -> 46.90%. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012MZnQwhZ2cjYqJdMdEo18X
… original encodes it The original tests the freshly incremented counter with 'cmp eax, 5' / 'jge', so spell the condition '5 <= x' rather than '4 < x'. 68.00% -> 72.00%. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012MZnQwhZ2cjYqJdMdEo18X
The original's epilogue sits in the middle of the stream, with the rally-point block outlined after it - the decompiler dropped the 'return' that ends the search once the matching laddermen tribe is found. 36.50% -> 93.70%. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012MZnQwhZ2cjYqJdMdEo18X
The original has epilogues at 37% and 52% of the stream: it returns as soon as it has committed the tribe to attacking a building or a unit, rather than falling through and issuing a move instruction as well. 72.80% -> 98.90%. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012MZnQwhZ2cjYqJdMdEo18X
The original returns from the two failure cases instead of nesting the success path two levels deep, which puts its first epilogue at 43% of the stream. 81.10% -> 89.20%. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012MZnQwhZ2cjYqJdMdEo18X
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
…e PR Measured with both resolver sets on, full build plus reccmp. Each remark names the blocker that is left. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Fix: the original returns, not continues, at the first tribe whose progress value is 11 or more or whose support tribe is still linked (both jumps go to the epilogue). The two support-tribe searches now jump straight to the link code, as the original does, and the update limit is stored before the behaviour type. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
…ores reg_scores.py (cdb) shows param_1, param_3 and param_4 all at benefit 4, so which two get a register falls to the symbol-id tiebreak; the callee-saved order already agrees with the original. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
…stere Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
…ebx; Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
This brings in the upstream ghidra changes from 0701799. Conflicts: - cmake/compiler-flags-gl.txt: kept both sides' entries. - src/precomp/addresses-SHC-3BB0A8C1.hpp: took main's version, because main's headers lead. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
These files are byte-identical to the ones in sourcehold#554 and sourcehold#555: TS_UNUSED = 0, TS_ACTIVE = 2, TS_DISBANDED = 3. The TS_ prefix relies on sourcehold#549 renaming TreeState's values to TSE_. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
- Main's AttackInfoDefinedData declares `MappersEnum field_0xc8[9]`, which is the array at 0xB4C7CC. The previous commit removed DAT_ARRAY_00b4c7cc.hpp together with the TribeState headers, and placeSiegeTentsAndAssignEngineers now reads DAT_AttackInfoDefinedData::instance.field_0xc8[k]. - The 5999 limit checks use main's new SSS_UNUSABLE_THRESHOLD. - initializeOrAdvanceAttackWave dropped from 100% to 46.8% with main's smaller struct declaration. It now takes sourcehold#554's version, which includes Map/Enums/TribeState.hpp and is back at 100%. - sortAttackInfoTribeIDArrayBasedOn: 76.0% -> 85.1%. The struct no longer overlaps the array labels, so the status line is updated. Normalized it is 68.0%, down from 71.5%. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Main's 87e40b6 adds Map/Enums/TribeState.hpp and TribeStateShort.hpp, byte-identical to this branch's copies. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
The two offsets are pushed as dwords by both callers and only the product is stored to a short field; with short parameters MSVC reads them as words and reorders the stores. Parameters named after their use. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
The behaviour type is stored right after the upper limit, as in the original; casts and the long-hand increment dropped. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Dead locals and the shadow copy of tribeIDArraySize removed, early return for the size limits, named locals for the sort; 85.1% -> 93.5%. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
…ineers to 97.9% The binary-map guard writes buildingPlacementFail and returns in its own arm, map constants and named tile coordinates, casts dropped. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
One sort call per scale3 bucket (MSVC tail-merges them into the original's per-arm pushes), the second signpost check reads currentPlayerSlotID again, the troop budget comparison is written the way round the original compares, redundant casts dropped. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.